package com.chpro.dubbo.demo1;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Consumer {
	 
    public static void main(String[] args) throws Exception {
        System.out.println(new Date());
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
        context.start();
        System.out.println(new Date());
        DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
        long i=1;
        while(true){
            String hello = demoService.sayHello("world"); // 执行远程方法
            //System.out.println(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
            System.out.println( hello+":"+i++ +"\t"+new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); // 显示调用结果
            //System.out.println(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
        }
    }
 
}